new Vue({
  el: '#app',
  data() {
    return {
      form: {
        Article_Name: "",
        Category_SerialNumber: "",
        Enterprise_Info_SerialNumber: "",
        Type: "0",
        token: $.cookie("token"),
        page: 1,			//页数
        limit: 10,			//每页数据条数
      },
      form1: {
        // Article_Name: "",
        hotspot: '1',  //0是消息1消息条数
        Type: "0",   //1是自己0是全部
        Row_Status: '',  //空是全部0是未读1是已读
        token: $.cookie("token"),
        Enterprise_Info_SerialNumber: $.cookie("enterprise"),
        page: 1,			//页数
        limit: 10,			//每页数据条数
      },
      Group_Purchasing_SerialNumber: '',
      total: 0,
      category: [],
      Enterprise: [],
      TransactionInstructions: false,
      badge: '',
      tableData: [],
      loading: false,
      Enterprise_Info_SerialNumber: $.cookie("enterprise")
    }
  },
  mounted() {
    //默认查询第一组数据
    this.getList(this.form)
    // 获取消息条数
    this.getList1(this.form1)
    //查询所有类别
    this.getCategoryData()
    //查询所有发布过采购的公司
    this.getEnterpriseData()
  },
  methods: {
    //通过关键字查询数据
    onSerach() {
      this.getList(this.form)
    },
    //通过选择类别查询数据
    change(e) {
      this.form.Category_SerialNumber = e
      this.getList(this.form)
    },
    //通过选择公司查询数据
    change1(e) {
      this.form.Enterprise_Info_SerialNumber = e
      this.getList(this.form)
    },
    //号码按键查询
    handleSizeChange(val) {
      this.form.page = 1;
      this.form.limit = val;
      this.getList(this.form)
    },
    //号码按键查询
    handleCurrentChange(val) {
      this.form.page = val;
      this.getList(this.form)
    },
    //分页查询数据
    getList(data) {
      let _this = this
      $.ajax({
        type: 'POST',
        data,
        url: DomainName + '/getGroupProcureAllAction',
        success: function (Result) {
          _this.tableData = Result.tableData;
          console.log(Result)
          _this.total = parseInt(Result.limit)
        },
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      })
    },
    // 获取消息条数
    getList1(data) {
      let _this = this
      $.ajax({
        type: 'POST',
        data,
        url: DomainName + '/getGroupMessageAllAction',
        success: function (Result) {
          // _this.tableData = Result.tableData;
          console.log(Result)
          _this.badge = Result.limit
          // _this.total = parseInt(Result.limit)
        },
        complete: function (XMLHttpRequest) {
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      })
    },
    //查询所有类别
    getCategoryData() {
      let _this = this
      $.ajax({
        type: 'POST',
        url: DomainName + "/GoodsFileInquiry",
        data: {
          Data: "category",
        },
        success: function (res) {
          _this.category = res
          console.log(res)
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      });
    },
    //查询所有公司
    getEnterpriseData() {
      let _this = this
      $.ajax({
        type: 'POST',
        url: DomainName + "/getGroupEnterpriseAllAction",
        data: {
          Data: "category",
          Type: '0',
          token: $.cookie("token")
        },
        success: function (res) {
          _this.Enterprise = res.Data
          console.log(res)
        },
        complete: function (XMLHttpRequest) {
          _this.loading = false
          if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
            window.parent.document.location.href = "../../../" + XMLHttpRequest.getResponseHeader("CONTENTPATH");
          }
        },
        dataType: "json"
      });
    },

    //跳转到消息界面
    mymessage() {
      window.location.href = './Message.html'
    },
    //跳转到增加界面
    addEnterprise() {
      window.location.href = './Add.html'
    },
    isTransactionInstructions(data) {
      this.TransactionInstructions = true
      this.Group_Purchasing_SerialNumber = data

    },
    //跳转到详情
    bidding() {
      sessionStorage.setItem("Group_Purchasing_SerialNumber", this.Group_Purchasing_SerialNumber)
      window.location.href = './Bidding.html?Group_Purchasing_SerialNumber=' + this.Group_Purchasing_SerialNumber

    },
    Seedetails(data) {
      window.location.href = './Detailrecords.html?Group_Purchasing_SerialNumber=' + data
      sessionStorage.setItem("Group_Purchasing_SerialNumber", data)
    },
    Business(data) {
      window.location.href = './Business.html?Enterprise_Info_SerialNumber=' + data
      sessionStorage.setItem("Enterprise_Info_SerialNumber", data)
    }
  },
})

